# -*- coding: utf-8 -*-
# @Author: lidongdong
# @time  : 19-6-4 下午2:52
# @file  : gridpanel.py

"""
usage:
"""
import matplotlib.pyplot as plt
import numpy as np


left, top, right, down = "← ↓ → ↑".split()
direction_list = [left, top, right, down]


def add_panel(height, width):
    """绘制panel"""
    plt.figure(figsize=(width, height))
    plt.axis("off")
    # 横线
    for i in range(height + 1):
        x1 = np.linspace(0, width)
        y1 = np.asarray([float(i)] * 50)
        plt.plot(x1, y1, "k-")

    # 竖线
    for i in range(width + 1):
        x1 = np.asarray([float(i)] * 50)
        y1 = np.linspace(0, height)
        plt.plot(x1, y1, "k-")


def add_arrow(x, y, direct, height=4):

    if isinstance(direct, int):
        direct = direction_list[direct]
    elif isinstance(direct, str):
        pass
    else:
        raise NotImplementedError("unknown type of {}".format(direct))

    plt.text(x + 0.35, height - (y + 0.65), direct, fontsize=20)


if __name__ == '__main__':
    add_panel(4, 4)
    add_arrow(2, 2, left)
    plt.show()
